var id = document.getElementById("id").value;
var abbreviation = document.getElementById("abbreviation").value;
var websocket = null;
if ('WebSocket' in window) {
    websocket = new WebSocket("ws://www.yiyatest.cn/websocket/" + id + '/' + abbreviation)
} else {
    alert('Not support websocket！该浏览器不支持实时刷新，请使用谷歌浏览器急速模式！')
};
websocket.onerror = function() {
    setMessageInnerHTML("error")
};
websocket.onopen = function(event) {
    setMessageInnerHTML("open")
};
websocket.onmessage = function(event) {
    setMessageInnerHTML(event.data)
};
websocket.onclose = function() {
    setMessageInnerHTML("close")
};
window.onbeforeunload = function() {
    websocket.close()
};

function setMessageInnerHTML(innerHTML) {
    btnRefetchEvents()
};

function closeWebSocket() {
    websocket.close()
};

function send() {
    var message = document.getElementById('text').value;
    websocket.send(message)
};